﻿#pragma once
namespace my_test {
	class TestTexture2D : public Test { // ̳ Test 
	private:
		float			position2D[16];
		unsigned int	indices2D[6];
		uint32_t		m_id;
		//unsigned int	vertex_array_id;
		//unsigned int	vertex_buffer;
		//unsigned int	index_buffer;
		//int				location;
		VertexArray			vertex_array = VertexArray(m_id);
		VertexBuffer		vertex_buffer = VertexBuffer(position2D, 4 * 4 * sizeof(float), m_id);
		VertexBufferLayout	layout;
		IndexBuffer			index_buffer = IndexBuffer(indices2D, 6, m_id);

		glm::vec3 translation = glm::vec3(0.0f, 200.0f, 0.0f);

	public:
		float m_alpha = 1.0f;
		std::unique_ptr<Shader>	 shader;
		std::unique_ptr<Texture> texture;
		struct {
			glm::mat4 projection;
			glm::mat4 view;
			glm::mat4 model;

			glm::mat4& operator[](uint8_t index) {
				if (index >= 3) {
					printf("[pvm Error]: Index out of range, returing identity matrix zero\n");
					glm::mat4 ret(0.0f);
					return ret;
				}
				else
					return (index == 0) ? projection : (index == 1) ? view : model;
			}
		} pvm;

		TestTexture2D() = delete;
		TestTexture2D(uint32_t id);
		//TestTexture2D(float red, float green, float blue, float alpha);
		~TestTexture2D() = default;

		void bind();
		void unbind();
		void up_date(float delta_time) override;
		void render() override;
		void imgui_render() override;
		void set_view_translation(glm::mat4 mat4, glm::vec3 vec3);
		void set_model_translation(glm::mat4 mat4, glm::vec3 vec3);
		void draw();
	};
}
